﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Timers;
using QunYing.Common;

namespace Client.OrderModule
{
    public class OrderInfoReceiver
    {
        public static OrderInfoReceiver Instance = new OrderInfoReceiver();
        IOrderInfoService wis;
        public void Start()
        {
            try
            {
                OrderInfoProcess order = new OrderInfoProcess();
                NetTcpBinding bind = new NetTcpBinding();
                bind.MaxReceivedMessageSize = 1024 * 1024;
                bind.ReaderQuotas.MaxArrayLength = 1024 * 1024;
                bind.ReaderQuotas.MaxStringContentLength = 1024 * 1024;
                bind.Security.Mode = SecurityMode.None;
                bind.ReceiveTimeout = TimeSpan.MaxValue;
                bind.ReliableSession.InactivityTimeout = TimeSpan.MaxValue;
                wis = DuplexChannelFactory<IOrderInfoService>.CreateChannel(order, bind, new EndpointAddress(QunYing.Common.GlobalInfo.ServiceBaseAddr + QunYing.Common.GlobalInfo.ServiceOrderInfoProcess));
                wis.RegisterListener(GlobalInfo.UserLoginInfo.用户ID, GlobalInfo.UserLoginInfo.角色);
            }
            catch (Exception ex)
            {
                GlobalInfo.MsgBoxShowError("订阅订单推送信息失败："+ex.Message);
                QunYing.Common.Loger.Log.Error("订阅订单推送信息失败：" + ex.Message);
            }

        }
    }
}
